package com.bank.common;

import java.util.ArrayList;

public class Cgenerator {  
      
	private static int num = 0;
	static ArrayList<String> Alist = new ArrayList<String>();
	private static ArrayList<String> Card = new ArrayList<String>();
	@SuppressWarnings("unused")
	private static boolean b;
    
     @SuppressWarnings("static-access")
	public void setCodeNumbers(ArrayList<String> Alist){
		this.Alist = Alist;	
	}
     
	public static String createCode() {  
			final String[] stringArray = {"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"};	
			final String[] intArray = {"1","2","3","4","5","6","7","8","9","0"};
			String codePart="";
			for(int i = 0;i<6;i++){
					num = 1 + (int)(Math.random()*2); 
			if(num<2){
					num = 0 + (int)(Math.random()*25);
					codePart = codePart.concat(stringArray[num]);
			}else{
					num = 0 + (int)(Math.random()*9);
					codePart = codePart.concat(intArray[num]);
			}
	}
	return codePart;
    }
	public static void createCodeCard() {
		Card.clear();
    	String s ="";
    	b = false;
    	int c = 0;
    	for(int i = 0;i<=49;i++){
    		
    		s = createCode();
    		for(int j = 0;j<Alist.size();j++){
    			if(Alist.get(j) != s){c++;}	
    		}
    		if(c == (Alist.size()-1)){b=true;}else{b=false;c=0;}
    			if(b = true){Alist.add(s);Card.add(s);c=0;}
    	}
    }
	public ArrayList<String> getCard() {  
        return Card;  
    }  
}  